package com.taplinker.client.im.protocol;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.taplinker.client.im.domain.ImDataCenter;

public class TapLinkerConversation {
	public static int PUBLIC_QUEUE = 1;
	public static int PRIVATE_QUEUE = 0;// 私有队列，可以添加至触客
	private String sdkAccount;

	private String id;

	private String customerId;

	private String customerName;

	// 咨询实体
	private ConsultEntriy product;

	// 咨询客户
	private String visitor;

	// 发起咨询的来源
	private String source;

	// 来源描述
	private String sourceDetail;

	// 咨询发起时间
	private Date createDate;

	// 更新时间
	private Date updateDate;

	// 当前客服
	private long userId;

	// 当前客服昵称
	private String nickname;

	// 企业Id
	private long enterpriseId;

	private String lastMessage;

	// apppkey
	private String appKey;

	// apppkey
	private String appName;

	// 将来替换
	private int unreadMessages;

	// 会话状态
	private String status;

	// 会话来源
	private String type;

	// 最后收到的消息类型
	private String messageType;

	private String pictures;

	// 原因
	private String reason;

	// 地址
	private String local;

	public String getLocal() {
		return local;
	}

	public void setLocal(String local) {
		this.local = local;
	}

	// 从哪里来的
	private long fromWho;

	private int queueType;

	public String getSdkAccount() {
		return sdkAccount;
	}

	public void setSdkAccount(String sdkAccount) {
		this.sdkAccount = sdkAccount;
	}

	public String getPictures() {
		return pictures;
	}

	public void setPictures(String pictures) {
		this.pictures = pictures;
	}

	public int getQueueType() {
		return queueType;
	}

	public void setQueueType(int queueType) {
		this.queueType = queueType;
	}

	private List<TapLinkerMessage> messages = new ArrayList<TapLinkerMessage>();

	// private boolean selected = false;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public ConsultEntriy getProduct() {
		return product;
	}

	public void setProduct(ConsultEntriy product) {
		this.product = product;
	}

	public String getVisitor() {
		return visitor;
	}

	public void setVisitor(String visitor) {
		this.visitor = visitor;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public long getEnterpriseId() {
		return enterpriseId;
	}

	public void setEnterpriseId(long enterpriseId) {
		this.enterpriseId = enterpriseId;
	}

	public String getLastMessage() {
		return lastMessage;
	}

	public void setLastMessage(String lastMessage) {
		this.lastMessage = lastMessage;
	}

	public String getAppKey() {
		return appKey;
	}

	public void setAppKey(String appKey) {
		this.appKey = appKey;
	}

	public String getAppName() {
		return appName;
	}

	public void setAppName(String appName) {
		this.appName = appName;
	}

	public int getUnreadMessages() {
		return unreadMessages;
	}

	public void setUnreadMessages(int unreadMessages) {
		this.unreadMessages = unreadMessages;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getMessageType() {
		return messageType;
	}

	public void setMessageType(String messageType) {
		this.messageType = messageType;
	}

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	public long getFromWho() {
		return fromWho;
	}

	public void setFromWho(long fromWho) {
		this.fromWho = fromWho;
	}

	public List<TapLinkerMessage> getMessages() {
		return messages;
	}

	public void setMessages(List<TapLinkerMessage> messages) {
		this.messages = messages;
	}

	public void setSourceDetail(String sourceDetail) {
		this.sourceDetail = sourceDetail;
	}

	public String getSourceDetail() {
		return sourceDetail;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}

	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}

	public String getCustomerName() {
		return customerName;
	}

	public void readMessage() {
		for (TapLinkerMessage message : messages) {
			message.setRead(true);
		}
		ImDataCenter.getInstance().noticeListener(id);
	}

	public void addMessage(TapLinkerMessage message) {
		messages.add(message);
		setLastMessage(message.getContent());
		setMessageType(message.getType());
		setUpdateDate(message.getSendTime());
		ImDataCenter.getInstance().noticeListener(id);
	}
}
